
import Router from 'koa-router'
import {Models} from '../../../common/typings/model'
import Result from '../../../common/utils/Result'
import Fiction from '../../../service/Fiction'
const router = new Router({
    prefix:'/api/v1/fiction'
})






router.get('/getFiction.do',async (ctx: Models.Ctx,next)=> {
    // const res = await CrawlerPlus.getFictionData('http://m.biquge3.com/js/main.js?rd=525')
    // // /js/main.js?rd=525
    // // http://m.biquge3.com/xs/1111262/

    // if(!res){
    //     ctx.body = Result.fail() 
    //     return 
    // }
    // const $:cheerio.Root = cheerio.load(res)
    // console.log($('body').text())
    try {
        // const results = await todo()
        // console.log(results!.text())
        const results = await Fiction.getList('http://m.biquge3.com/xs/1111262')
        ctx.body = Result.success({
            results
        })
    } catch (error) {
        console.log(error)
    }
    
})

export default router